/*
 * =====================================================================================
 *
 *       Filename:  segmentLibrary.cpp
 *
 *    Description:  Class implementation of segment library
 *
 *        Version:  1.0
 *        Created:  30/06/12 14:02:59
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Moos Hueting (mh), mooshueting@gmail.com
 *   Organization:  
 *
 * =====================================================================================
 */
#include <stdlib.h>
#include "segmentLibrary.h"
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

SegmentLibrary::SegmentLibrary(const char *listfile) {
    loadList(listfile);
}

void SegmentLibrary::loadList(const char *listfile) {
    ifstream list;
    list.open(listfile); // open the list of segment files

    string curfile;

    while (getline(list, curfile)) { // go through the list and get each line
        Segment curSegment(curfile.c_str()); // generate segment from line
        segments.push_back(curSegment);
    }
    list.close();
}

Segment SegmentLibrary::getSegment(int i) {
    return segments.at(i);
}

int SegmentLibrary::getSize() {
    return segments.size();
}
